package thread.example5;

/**
 * 主线程和守护线程一起启动 ，主线程挂了 守护线程也会挂掉
 */
public class DaemonDemo extends Thread{

    @Override
    public void run() {
        for (int i = 0; i < 500; i++) {
            System.out.println("Daemon"+i);
        }
    }

    public static void main(String[] args) {
        DaemonDemo t = new DaemonDemo();
        for (int i = 0; i < 50; i++) {
            System.out.println("main" + i);
            if (i == 10) {
                t.setDaemon(true);
                t.start();
            }
        }
    }
}

